

package com.dog.basics.admin.controller.wishwash.admin;

import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.R;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.wishwash.AdminDogHxDevNodeAddDto;
import com.dog.basics.bean.dto.admin.wishwash.AdminDogHxDevNodeEditDto;
import com.dog.basics.bean.dto.admin.wishwash.AdminDogHxDevNodeFromDto;
import com.dog.basics.bean.vo.admin.wishwash.AdminDogHxDevNodeVo;
import com.dog.basics.bean.vo.admin.wishwash.AdminDogHxDevNodeInfoVo;

import com.dog.basics.bean.model.wishwash.DogHxDevNode;
import com.dog.basics.service.wishwash.DogHxDevNodeService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 设备节点信息
 *
 * @author cy code generator
 * @date 2021-07-09 17:40:26
 */
@RestController
@AllArgsConstructor
@RequestMapping("/admin/devnode" )
@Api(value = "设备节点信息管理", tags = "设备节点信息管理")
public class DogHxDevNodeController {

    private final  DogHxDevNodeService dogHxDevNodeService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param obj 设备节点信息
     * @return
     * @author cy code generator
     * @date 2021-07-09 17:40:26
     */
    @ApiOperation(value = "分页查询", notes = "admin_doghxdevnode_view")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('admin_doghxdevnode_view')" )
    public R<IPage<AdminDogHxDevNodeVo>> getDogHxDevNodePage(PageParam page, AdminDogHxDevNodeFromDto obj) {
        return R.ok(dogHxDevNodeService.getAdminPageList(page,obj));
    }


    /**
     * 通过id查询设备节点信息
     * @param id id
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:26
     */
    @ApiOperation(value = "通过id查询", notes = "admin_doghxdevnode_info")
    @GetMapping("/{id}" )
    @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "Long")
    @PreAuthorize("@pms.hasPermission('admin_doghxdevnode_info')" )
    public R<AdminDogHxDevNodeInfoVo> getById(@PathVariable("id" ) Long id) {
        return R.ok(dogHxDevNodeService.getAdminObjXq(id));
    }

    /**
     * 新增设备节点信息
     * @param obj 设备节点信息
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:26
     */
    @ApiOperation(value = "新增设备节点信息", notes = "admin_doghxdevnode_add")
    @SysLog("新增设备节点信息" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('admin_doghxdevnode_add')" )
    public R<Boolean>  save(@Valid  @RequestBody AdminDogHxDevNodeAddDto obj) {
        return R.ok(dogHxDevNodeService.saveAdminObj(obj));
    }

    /**
     * 修改设备节点信息
     * @param obj 设备节点信息
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:26
     */
    @ApiOperation(value = "修改设备节点信息", notes = "admin_doghxdevnode_edit")
    @SysLog("修改设备节点信息" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('admin_doghxdevnode_edit')" )
    public R<Boolean> updateById(@Valid  @RequestBody AdminDogHxDevNodeEditDto obj) {
        return R.ok(dogHxDevNodeService.editAdminObj(obj));
    }

    /**
     * 通过id删除设备节点信息
     * @param id id
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:26
     */
    @ApiOperation(value = "通过id删除设备节点信息", notes = "admin_doghxdevnode_del")
    @SysLog("通过id删除设备节点信息" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('admin_doghxdevnode_del')" )
    @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "Long")
    public R<Boolean>  removeById(@PathVariable Long id) {
        return R.ok(dogHxDevNodeService.deleteObj(id));
    }

}
